package com.deloitte.snap.service;

import java.io.InputStream;
import java.util.Properties;

import com.deloitte.snap.dao.AbstractDAO;
import com.deloitte.snap.servlet.SpringContextLoaderServlet;
import com.deloitte.snap.util.FileUploadController;

public abstract class AbstractService {
	
	private static Properties prop=new Properties();
	static
	{
		try
		{
			InputStream is=FileUploadController.class.getClassLoader().getResourceAsStream("dbinfo.properties");			
			prop.load(is);
			is.close();		
		}
		catch(Exception exc)
		{
			exc.printStackTrace();
		}
	}
	public AbstractDAO getDAO(String beanName){
		return (AbstractDAO) getBean(beanName);
	}
	
	public static Object getBean(String beanName){
		return SpringContextLoaderServlet.getSpringWebApplicationContext().getBean(beanName);
	}
	
	public static String getProperty(String key){
		return prop.getProperty(key);
	}
}
